<?php
namespace Wap\Model;
use Think\Model;
/**
 * 数据处理
 */
class ApiModel extends Model {

    public  function getCode(){
        $phone=I('phone');
        $randCode=mt_rand(100000,999999);
        import('Vendor.yunsms');
        $sms = new \yunsms();
        if(!preg_match("/^1[3|4|5|7|8]{1}\d{9}$/",$phone)){
            return ['status'=>-2,'msg'=>'手机号码格式错误'];
        }
        $res = $sms->sendMsg($phone, $randCode . '啪啪啪助手平台验证码,五分钟内有效【啪啪啪助手】');
        if($res['status']==1){
            return ['status'=>1,'msg'=>'短信发送成功','data'=>['userPhone'=>$userPhone,'code'=>$randCode]];
        }else{
            return ['status'=>0,'msg'=>'短信发送失败'];
        }
    }
}